package com.mapapp.flutter_mapapp.adapter;

import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.view.View;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.mapapp.flutter_mapapp.R;

import java.util.List;

public class OperationAdapter extends BaseQuickAdapter<OperationAdapter.ErrorCorrectionBean, BaseViewHolder> {


    public OperationAdapter(int layoutResId, @Nullable List<ErrorCorrectionBean> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(@NonNull BaseViewHolder helper, ErrorCorrectionBean item) {
        helper.setText(R.id.text_view, item.getName());
        helper.getView(R.id.text_view).setSelected(item.isSelected());


        //纠错 其他不用分割线
        if (getData().indexOf(item) == 2 || getData().indexOf(item) == 3) {
            helper.getView(R.id.divider).setVisibility(View.GONE);
        } else {
            helper.getView(R.id.divider).setVisibility(View.VISIBLE);
        }
    }

    public static class ErrorCorrectionBean {
        private String name;
        private boolean selected;

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

        public boolean isSelected() {
            return selected;
        }

        public void setSelected(boolean selected) {
            this.selected = selected;
        }
    }
}
